import {isEmpty} from './utils'
import os from 'os'
import fs from 'fs'
import {warning} from './logging'

export function addOutput(output: string): void {
    if (isEmpty(output)) {
        return
    }

    const flowOutputFile: string | undefined = process.env['FLOW_OUTPUT']
    if (flowOutputFile == undefined) {
        warning("!!!missing 'FLOW_OUTPUT' environment, ignore the output!!!")
        return
    }
    fs.appendFileSync(flowOutputFile, output + os.EOL, {encoding: 'utf8'})
}
